

#include "App_Main.h"
#include "chip.h"
#include "../LCD/UI.h"
#include "FactoryTest.h"
#include "GN1621.h"


void App_Init(void)
{
    GPIOConfig();
    GN1621_Init();
	UI_Init();
    // SystemConfig();
    FanCtrlInit();
    Key_Init();
    EncoderInit();
    ADInit();
    Buzzer_Init();
    Zero_Init();

    TuYa_Init();

    Factory_Main();
}

void App_Main(void)
{
    UI_Main();
    // if(Factory_Check_Enable > 0) Factory_Check_Enable = 0;
    KeyDetection();
	EncoderClock();
    EncoderMain();
    // Lcd_Show_Ctrl(Switch_State);
    // WDT_Clear();
    TempADC_Main();

    if(RTD[0].status == Pt_Normal)
    {
        HeatingFanCtrl();
        IgniterCtrl();
        ExhaustFanCtrl();
    }
    else
    {
        IgniterClose;
        HeaterFanClose;
        ExhaustFanClose;
    }
    ZHT104C_Main();

    TuYa_Main();
}

//Tick 10ms
void SysTick_IRQHandler(void)
{
	static uint8_t UI_Count = 0;
	UI_Count ++;
//    if((UI_Refresh_Count > 0) && (UI_Refresh_Count < 0xffff)) UI_Refresh_Count++;
    // if(Factory_Check_Enable == 1) ADC_Clock();
    
    // if(Switch_State == Temp_Shutoff) return;

    ADC_Clock();
    FanCtrlClock();
    // Buzzer_clock();
    UI_Clock();
	if(UI_Count>20)
	{
		UI_Count = 0;
		GN1621_Clock();
	}
	Lcd_Parts_Clock();
    ZHT104C_Clock();
    TuYa_Clock();
}
